﻿//Tên form : Tạo người dùng
//Người thực hiện: Huypvt - Ngày tạo : 06-02-05
//Mô tả: - Tạo người dùng cho hệ thống
//Mô tả chi tiết các chức năng :
//		- Nhập đầy đủ thông tin người dùng, chọn nhóm cho người dùng.
//Các yêu cầu ràng buộc : Mọi thông tin thay đổi phải thông báo đến người dùng,
//kiểm tra ràng buộc trước khi lưu vào cơ sở dữ liệu.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Infragistics.Win.Misc;
using System.Data;
using QLNHK.BLL;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win.UltraWinTree;
using Infragistics.Win.UltraWinEditors;
using System.Web.Caching;
using Infragistics.Win;
using QLNHK.Controls;


namespace QLNHK.QUANTRIHETHONG
{
    /// <summary>
    /// Summary description for frmTaoNguoiDung.
    /// </summary>
    public class FrmTaoNguoiDung : FrmBase
    {
        #region Variable Members
        private enum SaveSuaHayThem
        {
            SChinhSua,
            SThemMoi
        }
        private bool _bChangePass;
        private bool _isChange = false;
        private string _caption;

        public int intSuaHayThem;
        public int intID_NguoiDung;
        private DataTable dtHoSoNhanSu;
        private Cls_NGUOIDUNG objNguoiDung;
        private Cls_NHOM_NGUOIDUNG objNhomNguoiDung;
        private Cls_NHOM_NGUOIDUNG_CHITIET objNhomNguoiDungChiTiet;
        private System.Windows.Forms.Label label1;
        public Infragistics.Win.UltraWinEditors.UltraTextEditor txtNguoiDung;
        public Infragistics.Win.UltraWinGrid.UltraCombo cboHoSoNhanSu;
        private System.Windows.Forms.Label label2;
        public Infragistics.Win.UltraWinEditors.UltraTextEditor txtMatKhau;
        private System.Windows.Forms.Label label3;
        private Infragistics.Win.UltraWinGrid.UltraGrid UGNhomNguoiDung;
        private System.Data.DataSet dsNhomNguoiDung;
        private System.Data.DataTable dtNhomNguoiDung;
        private System.Data.DataColumn dataColumn1;
        private System.Data.DataColumn dataColumn2;
        private System.Data.DataColumn dataColumn3;
        private System.Windows.Forms.Panel panel1;
        private Infragistics.Win.Misc.UltraButton btnLuu;
        private Infragistics.Win.Misc.UltraButton btnDong;
        private System.Windows.Forms.Label label6;
        public Infragistics.Win.UltraWinEditors.UltraTextEditor txtXacNhanMatKhau;
        public Infragistics.Win.UltraWinEditors.UltraCheckEditor chkKichHoat;
        private System.Windows.Forms.ErrorProvider errorUser;
        //private Infragistics.Win.Misc.UltraButton btnThemNhom;
        private System.Windows.Forms.ImageList imgGrid;
        private UltraLabel ultraLabel1;
        private System.ComponentModel.IContainer components;
        #endregion

        #region Constructors
        public FrmTaoNguoiDung()
        {
            InitializeComponent();
        }
        #endregion
        #region Dispose
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        #endregion

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance13 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance14 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance15 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance16 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance17 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance18 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance19 = new Infragistics.Win.Appearance();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmTaoNguoiDung));
            Infragistics.Win.Appearance appearance20 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance21 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance22 = new Infragistics.Win.Appearance();
            this.label1 = new System.Windows.Forms.Label();
            this.txtNguoiDung = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
            this.cboHoSoNhanSu = new Infragistics.Win.UltraWinGrid.UltraCombo();
            this.label2 = new System.Windows.Forms.Label();
            this.txtMatKhau = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
            this.label3 = new System.Windows.Forms.Label();
            this.UGNhomNguoiDung = new Infragistics.Win.UltraWinGrid.UltraGrid();
            this.imgGrid = new System.Windows.Forms.ImageList(this.components);
            this.dsNhomNguoiDung = new System.Data.DataSet();
            this.dtNhomNguoiDung = new System.Data.DataTable();
            this.dataColumn1 = new System.Data.DataColumn();
            this.dataColumn2 = new System.Data.DataColumn();
            this.dataColumn3 = new System.Data.DataColumn();
            this.chkKichHoat = new Infragistics.Win.UltraWinEditors.UltraCheckEditor();
            this.panel1 = new System.Windows.Forms.Panel();
            this.btnLuu = new Infragistics.Win.Misc.UltraButton();
            this.btnDong = new Infragistics.Win.Misc.UltraButton();
            this.ultraLabel1 = new Infragistics.Win.Misc.UltraLabel();
            this.label6 = new System.Windows.Forms.Label();
            this.txtXacNhanMatKhau = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
            this.errorUser = new System.Windows.Forms.ErrorProvider(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.txtNguoiDung)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.cboHoSoNhanSu)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.txtMatKhau)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.UGNhomNguoiDung)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dsNhomNguoiDung)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dtNhomNguoiDung)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.chkKichHoat)).BeginInit();
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.txtXacNhanMatKhau)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.errorUser)).BeginInit();
            this.SuspendLayout();
            // 
            // imgList
            // 
            this.imgList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
            this.imgList.ImageSize = new System.Drawing.Size(16, 16);
            this.imgList.ImageStream = null;
            // 
            // label1
            // 
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left)));
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(257, 60);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(80, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Hồ sơ nhân sự:";
            this.label1.Visible = false;
            // 
            // txtNguoiDung
            // 
            this.txtNguoiDung.Location = new System.Drawing.Point(112, 7);
            this.txtNguoiDung.Name = "txtNguoiDung";
            this.txtNguoiDung.Size = new System.Drawing.Size(272, 22);
            this.txtNguoiDung.TabIndex = 1;
            // 
            // cboHoSoNhanSu
            // 
            this.cboHoSoNhanSu.CheckedListSettings.CheckStateMember = "";
            appearance1.BackColor = System.Drawing.SystemColors.Window;
            appearance1.BorderColor = System.Drawing.SystemColors.InactiveCaption;
            this.cboHoSoNhanSu.DisplayLayout.Appearance = appearance1;
            this.cboHoSoNhanSu.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
            this.cboHoSoNhanSu.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;
            appearance2.BackColor = System.Drawing.SystemColors.ActiveBorder;
            appearance2.BackColor2 = System.Drawing.SystemColors.ControlDark;
            appearance2.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            appearance2.BorderColor = System.Drawing.SystemColors.Window;
            this.cboHoSoNhanSu.DisplayLayout.GroupByBox.Appearance = appearance2;
            appearance3.ForeColor = System.Drawing.SystemColors.GrayText;
            this.cboHoSoNhanSu.DisplayLayout.GroupByBox.BandLabelAppearance = appearance3;
            this.cboHoSoNhanSu.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
            appearance4.BackColor = System.Drawing.SystemColors.ControlLightLight;
            appearance4.BackColor2 = System.Drawing.SystemColors.Control;
            appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
            appearance4.ForeColor = System.Drawing.SystemColors.GrayText;
            this.cboHoSoNhanSu.DisplayLayout.GroupByBox.PromptAppearance = appearance4;
            this.cboHoSoNhanSu.DisplayLayout.MaxColScrollRegions = 1;
            this.cboHoSoNhanSu.DisplayLayout.MaxRowScrollRegions = 1;
            appearance5.BackColor = System.Drawing.SystemColors.Window;
            appearance5.ForeColor = System.Drawing.SystemColors.ControlText;
            this.cboHoSoNhanSu.DisplayLayout.Override.ActiveCellAppearance = appearance5;
            appearance6.BackColor = System.Drawing.SystemColors.Highlight;
            appearance6.ForeColor = System.Drawing.SystemColors.HighlightText;
            this.cboHoSoNhanSu.DisplayLayout.Override.ActiveRowAppearance = appearance6;
            this.cboHoSoNhanSu.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Dotted;
            this.cboHoSoNhanSu.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Dotted;
            appearance7.BackColor = System.Drawing.SystemColors.Window;
            this.cboHoSoNhanSu.DisplayLayout.Override.CardAreaAppearance = appearance7;
            appearance8.BorderColor = System.Drawing.Color.Silver;
            appearance8.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
            this.cboHoSoNhanSu.DisplayLayout.Override.CellAppearance = appearance8;
            this.cboHoSoNhanSu.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.EditAndSelectText;
            this.cboHoSoNhanSu.DisplayLayout.Override.CellPadding = 0;
            appearance9.BackColor = System.Drawing.SystemColors.Control;
            appearance9.BackColor2 = System.Drawing.SystemColors.ControlDark;
            appearance9.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
            appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
            appearance9.BorderColor = System.Drawing.SystemColors.Window;
            this.cboHoSoNhanSu.DisplayLayout.Override.GroupByRowAppearance = appearance9;
            appearance10.TextHAlignAsString = "Left";
            this.cboHoSoNhanSu.DisplayLayout.Override.HeaderAppearance = appearance10;
            this.cboHoSoNhanSu.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
            this.cboHoSoNhanSu.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
            appearance11.BackColor = System.Drawing.SystemColors.Window;
            appearance11.BorderColor = System.Drawing.Color.Silver;
            this.cboHoSoNhanSu.DisplayLayout.Override.RowAppearance = appearance11;
            this.cboHoSoNhanSu.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False;
            appearance12.BackColor = System.Drawing.SystemColors.ControlLight;
            this.cboHoSoNhanSu.DisplayLayout.Override.TemplateAddRowAppearance = appearance12;
            this.cboHoSoNhanSu.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
            this.cboHoSoNhanSu.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
            this.cboHoSoNhanSu.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;
            this.cboHoSoNhanSu.DropDownStyle = Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDownList;
            this.cboHoSoNhanSu.Location = new System.Drawing.Point(361, 52);
            this.cboHoSoNhanSu.Name = "cboHoSoNhanSu";
            this.cboHoSoNhanSu.PreferredDropDownSize = new System.Drawing.Size(0, 0);
            this.cboHoSoNhanSu.Size = new System.Drawing.Size(92, 23);
            this.cboHoSoNhanSu.TabIndex = 0;
            this.cboHoSoNhanSu.Visible = false;
            this.cboHoSoNhanSu.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.cboHoSoNhanSu_InitializeLayout);
            // 
            // label2
            // 
            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left)));
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(8, 15);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(83, 13);
            this.label2.TabIndex = 0;
            this.label2.Text = "Tên đăng nhâp:";
            // 
            // txtMatKhau
            // 
            this.txtMatKhau.Location = new System.Drawing.Point(112, 34);
            this.txtMatKhau.MaxLength = 20;
            this.txtMatKhau.Name = "txtMatKhau";
            this.txtMatKhau.PasswordChar = '*';
            this.txtMatKhau.Size = new System.Drawing.Size(120, 22);
            this.txtMatKhau.TabIndex = 2;
            this.txtMatKhau.TextChanged += new System.EventHandler(this.txtMatKhau_TextChanged);
            // 
            // label3
            // 
            this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left)));
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(8, 42);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(55, 13);
            this.label3.TabIndex = 0;
            this.label3.Text = "Mật khẩu:";
            // 
            // UGNhomNguoiDung
            // 
            this.UGNhomNguoiDung.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            appearance13.BackColor = System.Drawing.Color.White;
            appearance13.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(151)))), ((int)(((byte)(253)))));
            appearance13.BackGradientStyle = Infragistics.Win.GradientStyle.ForwardDiagonal;
            this.UGNhomNguoiDung.DisplayLayout.Appearance = appearance13;
            this.UGNhomNguoiDung.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;
            appearance14.FontData.BoldAsString = "True";
            appearance14.TextHAlignAsString = "Left";
            appearance14.TextVAlignAsString = "Middle";
            this.UGNhomNguoiDung.DisplayLayout.CaptionAppearance = appearance14;
            this.UGNhomNguoiDung.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.True;
            this.UGNhomNguoiDung.DisplayLayout.InterBandSpacing = 10;
            this.UGNhomNguoiDung.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
            this.UGNhomNguoiDung.DisplayLayout.Override.AllowGroupBy = Infragistics.Win.DefaultableBoolean.False;
            this.UGNhomNguoiDung.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.True;
            appearance15.BackColor = System.Drawing.Color.Transparent;
            this.UGNhomNguoiDung.DisplayLayout.Override.CardAreaAppearance = appearance15;
            this.UGNhomNguoiDung.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.Edit;
            appearance16.BackColor = System.Drawing.Color.White;
            appearance16.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(181)))), ((int)(((byte)(234)))), ((int)(((byte)(253)))));
            appearance16.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            appearance16.FontData.BoldAsString = "False";
            appearance16.FontData.Name = "Tahoma";
            appearance16.FontData.SizeInPoints = 8F;
            appearance16.ForeColor = System.Drawing.Color.Black;
            appearance16.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent;
            this.UGNhomNguoiDung.DisplayLayout.Override.HeaderAppearance = appearance16;
            this.UGNhomNguoiDung.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
            appearance17.BorderColor = System.Drawing.Color.DodgerBlue;
            this.UGNhomNguoiDung.DisplayLayout.Override.RowAppearance = appearance17;
            appearance18.BackColor = System.Drawing.Color.White;
            appearance18.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(181)))), ((int)(((byte)(234)))), ((int)(((byte)(253)))));
            appearance18.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            this.UGNhomNguoiDung.DisplayLayout.Override.RowSelectorAppearance = appearance18;
            this.UGNhomNguoiDung.DisplayLayout.Override.RowSpacingBefore = 0;
            appearance19.BackColor = System.Drawing.Color.White;
            appearance19.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(181)))), ((int)(((byte)(234)))), ((int)(((byte)(253)))));
            appearance19.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            appearance19.ForeColor = System.Drawing.Color.Black;
            this.UGNhomNguoiDung.DisplayLayout.Override.SelectedRowAppearance = appearance19;
            this.UGNhomNguoiDung.DisplayLayout.RowConnectorColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(151)))), ((int)(((byte)(253)))));
            this.UGNhomNguoiDung.DisplayLayout.RowConnectorStyle = Infragistics.Win.UltraWinGrid.RowConnectorStyle.None;
            this.UGNhomNguoiDung.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.UGNhomNguoiDung.ImageList = this.imgGrid;
            this.UGNhomNguoiDung.Location = new System.Drawing.Point(8, 89);
            this.UGNhomNguoiDung.Name = "UGNhomNguoiDung";
            this.UGNhomNguoiDung.Size = new System.Drawing.Size(454, 179);
            this.UGNhomNguoiDung.TabIndex = 4;
            this.UGNhomNguoiDung.Text = "Nhóm người dùng ";
            this.UGNhomNguoiDung.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.UGNhomNguoiDung_InitializeLayout);
            this.UGNhomNguoiDung.CellChange += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.UGNhomNguoiDung_CellChange);
            this.UGNhomNguoiDung.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.UGNhomNguoiDung_ClickCellButton);
            // 
            // imgGrid
            // 
            this.imgGrid.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgGrid.ImageStream")));
            this.imgGrid.TransparentColor = System.Drawing.Color.Transparent;
            this.imgGrid.Images.SetKeyName(0, "user.ico");
            this.imgGrid.Images.SetKeyName(1, "users.ico");
            // 
            // dsNhomNguoiDung
            // 
            this.dsNhomNguoiDung.DataSetName = "NewDataSet";
            this.dsNhomNguoiDung.Locale = new System.Globalization.CultureInfo("en-US");
            this.dsNhomNguoiDung.Tables.AddRange(new System.Data.DataTable[] {
            this.dtNhomNguoiDung});
            // 
            // dtNhomNguoiDung
            // 
            this.dtNhomNguoiDung.Columns.AddRange(new System.Data.DataColumn[] {
            this.dataColumn1,
            this.dataColumn2,
            this.dataColumn3});
            this.dtNhomNguoiDung.TableName = "tb_NHOM_NGUOIDUNG";
            // 
            // dataColumn1
            // 
            this.dataColumn1.ColumnName = "ID_NhomNguoiDung";
            this.dataColumn1.DataType = typeof(int);
            // 
            // dataColumn2
            // 
            this.dataColumn2.ColumnName = "Ten_NhomNguoiDung";
            // 
            // dataColumn3
            // 
            this.dataColumn3.ColumnName = "TrangThai";
            this.dataColumn3.DataType = typeof(bool);
            this.dataColumn3.DefaultValue = false;
            // 
            // chkKichHoat
            // 
            this.chkKichHoat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.chkKichHoat.Location = new System.Drawing.Point(8, 272);
            this.chkKichHoat.Name = "chkKichHoat";
            this.chkKichHoat.Size = new System.Drawing.Size(80, 20);
            this.chkKichHoat.TabIndex = 5;
            this.chkKichHoat.Text = "Kích hoạt";
            // 
            // panel1
            // 
            this.panel1.BackColor = System.Drawing.Color.WhiteSmoke;
            this.panel1.Controls.Add(this.btnLuu);
            this.panel1.Controls.Add(this.btnDong);
            this.panel1.Controls.Add(this.ultraLabel1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel1.Location = new System.Drawing.Point(0, 295);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(478, 32);
            this.panel1.TabIndex = 9;
            // 
            // btnLuu
            // 
            this.btnLuu.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            appearance20.Image = ((object)(resources.GetObject("appearance20.Image")));
            this.btnLuu.Appearance = appearance20;
            this.btnLuu.BackColorInternal = System.Drawing.SystemColors.Control;
            this.btnLuu.Enabled = false;
            this.btnLuu.Location = new System.Drawing.Point(285, 4);
            this.btnLuu.Name = "btnLuu";
            this.btnLuu.Size = new System.Drawing.Size(102, 24);
            this.btnLuu.TabIndex = 0;
            this.btnLuu.Text = "&Lưu";
            this.btnLuu.Click += new System.EventHandler(this.BtnEvent_Click);
            // 
            // btnDong
            // 
            this.btnDong.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            appearance21.Image = ((object)(resources.GetObject("appearance21.Image")));
            this.btnDong.Appearance = appearance21;
            this.btnDong.BackColorInternal = System.Drawing.SystemColors.Control;
            this.btnDong.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnDong.Location = new System.Drawing.Point(393, 4);
            this.btnDong.Name = "btnDong";
            this.btnDong.Size = new System.Drawing.Size(77, 24);
            this.btnDong.TabIndex = 1;
            this.btnDong.Text = "Đó&ng";
            this.btnDong.Click += new System.EventHandler(this.BtnEvent_Click);
            // 
            // ultraLabel1
            // 
            appearance22.BackColor = System.Drawing.Color.White;
            appearance22.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            appearance22.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            this.ultraLabel1.Appearance = appearance22;
            this.ultraLabel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.ultraLabel1.Location = new System.Drawing.Point(0, 0);
            this.ultraLabel1.Name = "ultraLabel1";
            this.ultraLabel1.Size = new System.Drawing.Size(478, 32);
            this.ultraLabel1.TabIndex = 11;
            // 
            // label6
            // 
            this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left)));
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(8, 66);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(102, 13);
            this.label6.TabIndex = 7;
            this.label6.Text = "Xác nhận mật khẩu:";
            // 
            // txtXacNhanMatKhau
            // 
            this.txtXacNhanMatKhau.Location = new System.Drawing.Point(112, 61);
            this.txtXacNhanMatKhau.Name = "txtXacNhanMatKhau";
            this.txtXacNhanMatKhau.PasswordChar = '*';
            this.txtXacNhanMatKhau.Size = new System.Drawing.Size(120, 22);
            this.txtXacNhanMatKhau.TabIndex = 3;
            this.txtXacNhanMatKhau.TextChanged += new System.EventHandler(this.txtMatKhau_TextChanged);
            // 
            // errorUser
            // 
            this.errorUser.ContainerControl = this;
            // 
            // FrmTaoNguoiDung
            // 
            this.AcceptButton = this.btnLuu;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
            this.BackColor = System.Drawing.Color.White;
            this.CancelButton = this.btnDong;
            this.ClientSize = new System.Drawing.Size(478, 327);
            this.Controls.Add(this.UGNhomNguoiDung);
            this.Controls.Add(this.txtXacNhanMatKhau);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.chkKichHoat);
            this.Controls.Add(this.cboHoSoNhanSu);
            this.Controls.Add(this.txtNguoiDung);
            this.Controls.Add(this.txtMatKhau);
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimumSize = new System.Drawing.Size(480, 352);
            this.Name = "FrmTaoNguoiDung";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmTaoNguoiDung_Closing);
            this.Load += new System.EventHandler(this.FrmTaoNguoiDung_Load);
            ((System.ComponentModel.ISupportInitialize)(this.txtNguoiDung)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.cboHoSoNhanSu)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.txtMatKhau)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.UGNhomNguoiDung)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dsNhomNguoiDung)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dtNhomNguoiDung)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.chkKichHoat)).EndInit();
            this.panel1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.txtXacNhanMatKhau)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.errorUser)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }
        #endregion

        #region Form Events
        #region All_ValueChanged
        /// Author: khanhlq . Date: 2/11/2006.
        /// Modifier: khanhlq. Date:  2/11/2006.
        /// Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Handles the ValueChanged event of the All control.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>
        public void All_ValueChanged(object sender, System.EventArgs e)
        {
            setChanged(this._isChange = true);
        }
        #endregion

        #region BtnEvent_Click
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Handles the Click event of the BtnEvent control.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>
        private void BtnEvent_Click(object sender, System.EventArgs e)
        {
            UltraButton btn = (UltraButton)(sender);
            switch (btn.Name)
            {
                case "btnLuu":
                    if (!Valid())
                        return;
                    if (_bChangePass)
                    {
                        if (!ValidPass())
                            return;
                    }
                    if (intSuaHayThem == 0)
                    {
                        Save(SaveSuaHayThem.SThemMoi);
                    }
                    else if (intSuaHayThem == 1)
                    {

                        Save(SaveSuaHayThem.SChinhSua);
                    }
                    break;
                case "btnDong":
                    this.Close();
                    break;
            }
        }
        #endregion
        private bool Valid()
        {
            if (cboHoSoNhanSu.Value == DBNull.Value)
            {
                SetError(cboHoSoNhanSu, true);
                return false;
            }
            else
                SetError(cboHoSoNhanSu, false);
            if (txtNguoiDung.Text == "")
            {
                SetError(txtNguoiDung, true);
                return false;
            }
            else
                SetError(txtNguoiDung, false);
            return true;
        }
        private bool ValidPass()
        {
            if (txtMatKhau.Text == "")
            {
                SetError(txtMatKhau, true);
                return false;
            }
            else
                SetError(txtMatKhau, false);
            if (blverifyValidate())
                return false;
            if (txtXacNhanMatKhau.Text != txtMatKhau.Text)
            {
                SetError(txtXacNhanMatKhau, true);
                return false;
            }
            else
                SetError(txtXacNhanMatKhau, false);
            return true;
        }
        private void SetError(Control Ctr, bool b)
        {
            switch (Ctr.Name)
            {
                case "cboHoSoNhanSu":
                    if (b)
                        errorUser.SetError(Ctr, "Yêu cầu chọn nhân sự cụ thể để thao tác");
                    else
                        errorUser.SetError(Ctr, "");
                    break;
                case "txtNguoiDung":
                    if (b)
                        errorUser.SetError(Ctr, "Yêu cầu tên người dùng không được rỗng");
                    else
                        errorUser.SetError(Ctr, "");
                    break;
                case "txtMatKhau":
                    if (b)
                        errorUser.SetError(Ctr, "Yêu cầu mật khẩu không được rỗng");
                    else
                        errorUser.SetError(Ctr, "");
                    break;
                case "txtXacNhanMatKhau":
                    if (b)
                        errorUser.SetError(Ctr, "Yêu cầu xác nhận mật khẩu không trùng khớp");
                    else

                        errorUser.SetError(Ctr, "");
                    break;
            }

        }
        #region FrmTaoNguoiDung_Load
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Xử lý khi form FrmTaoNguoiDung load.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>

        private void FrmTaoNguoiDung_Load(object sender, System.EventArgs e)
        {
            try
            {
                //dtHoSoNhanSu = Cls_FrequentlyAccess.getDanhSachNhanSu();
                ////(CacheUtil.Cache.Get("NhanSuCache") as DataView).Table;
                //if (dtHoSoNhanSu.Columns.Count <= 7)
                //{
                //    DataColumn col = new DataColumn();
                //    col.ColumnName = "HoTen";
                //    col.DataType = typeof(String);
                //    col.Expression = "Ho_Lot + ' ' + Ten";
                //    dtHoSoNhanSu.Columns.Add(col);
                //}
                //dtHoSoNhanSu.AcceptChanges();
                //cboHoSoNhanSu.UpdateData();
                //cboHoSoNhanSu.DataSource = dtHoSoNhanSu;
                objNguoiDung = new Cls_NGUOIDUNG();
                objNhomNguoiDungChiTiet = new Cls_NHOM_NGUOIDUNG_CHITIET();
                LayNguoiDungChiTiet();
                if (intSuaHayThem == 1)
                {
                    this.Text = "Chỉnh sửa người dùng";
                    this._caption = this.Text;
                    UpdateGridNguoiDungChiTiet();
                    _bChangePass = false;
                }
                else
                {
                    _bChangePass = true;
                    this.Text = "Tạo người dùng";
                    this._caption = this.Text;
                    cboHoSoNhanSu.ValueChanged += new System.EventHandler(All_ValueChanged);
                    txtNguoiDung.ValueChanged += new System.EventHandler(All_ValueChanged);
                    txtMatKhau.ValueChanged += new System.EventHandler(All_ValueChanged);
                    txtXacNhanMatKhau.ValueChanged += new System.EventHandler(All_ValueChanged);
                    chkKichHoat.TextChanged += new System.EventHandler(All_ValueChanged);
                }
            }
            catch (Exception ex)
            {
                Logger.LocalLogger.Instance().WriteMessage(ex);
            }
        }
        #endregion

        #region cboHoSoNhanSu_InitializeLayout
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Khởi tạo cho combo Hồ sơ nhân sự
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>
        private void cboHoSoNhanSu_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            UltraComboControls.SetComboStyle(cboHoSoNhanSu);
            cboHoSoNhanSu.ValueMember = "ID_HoSo_NhanSu";
            cboHoSoNhanSu.DisplayMember = "HoTen";
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["HoTen"].Hidden = true;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["ID_HoSo_NhanSu"].Hidden = true;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["ChucVu"].Hidden = true;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["PhongBan"].Hidden = true;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["ID_DM_LoaiKy"].Hidden = true;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["ID_DM_LoaiCa"].Hidden = true;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["GioiTinh"].Hidden = true;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["Ma_NV"].Header.Caption = "Mã NV";
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["Ma_NV"].Header.VisiblePosition = 0;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["Ho_Lot"].Header.Caption = "Họ";
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["Ho_Lot"].Header.VisiblePosition = 1;
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["Ten"].Header.Caption = "Tên";
            cboHoSoNhanSu.DisplayLayout.Bands[0].Columns["Ten"].Header.VisiblePosition = 2;
            cboHoSoNhanSu.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;
        }
        #endregion

        #region UGNhomNguoiDung_InitializeLayout

        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Handles the InitializeLayout event of the UGNhomNguoiDung control.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>
        private void UGNhomNguoiDung_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            UltraGridControls.SetGridStyle(UGNhomNguoiDung);
            UltraGridBand ugBand = UGNhomNguoiDung.DisplayLayout.Bands[0];
            HeaderCheckBoxCreationFilter filter = new HeaderCheckBoxCreationFilter();

            // Attach an event handler for when the CheckBox in the column header is clicked.
            filter.CheckChanged += new HeaderCheckBoxCreationFilter.HeaderCheckBoxClickedHandler(OnHeaderCheckBoxCheckChanged);

            // Assign the creation filter to the grid's CreationFilter property.
            this.UGNhomNguoiDung.CreationFilter = filter;

            ugBand.Columns["ID_Nhom_NguoiDung"].Hidden = true;
            ugBand.Columns["Ten"].Header.Caption = "Tên nhóm";
            ugBand.Columns["Ten"].CellAppearance.Image = imgGrid.Images[1];
            ugBand.Columns["Ten"].CellActivation = Activation.NoEdit;
            ugBand.Columns["MoTa"].Header.Caption = "Mô tả";
            ugBand.Columns["MoTa"].CellActivation = Activation.NoEdit;
            ugBand.Columns["Tick"].Header.Caption = "Chọn";
            ugBand.Columns["IsAdminGroup"].Hidden = true;
            UGNhomNguoiDung.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;
        }
        protected void OnHeaderCheckBoxCheckChanged(object sender, HeaderCheckBoxCreationFilter.HeaderCheckBoxEventArgs e)
        {
            // Loop over all of the rows in the first band and set the value of the cell in the 
            // column whose header's CheckBox was clicked.
            foreach (UltraGridRow row in this.UGNhomNguoiDung.Rows)
            {
                row.Cells[e.Column.Key].Value = e.CurrentCheckState;
                this.setChanged(true);
            }
            // Calling UpdateData will remove the "pencil" icons in the row selectors of the 
            // grid.  That icon appears when a row has been edited.
            this.UGNhomNguoiDung.UpdateData();
        }
        #endregion


        #region UGNhomNguoiDung_CellChange
        private void UGNhomNguoiDung_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
        {
            setChanged(this._isChange = true);
            int i = 0;
            foreach (UltraGridRow row in UGNhomNguoiDung.Rows)
            {
                //nếu Tick thay đổi từ true sang false 
                //thì sẽ xóa dữ liệu
                if (row.Cells["Tick"].Text == "True")
                {
                    i++;
                }
            }
            if (i == UGNhomNguoiDung.Rows.Count)
            {
            }
        }
        #endregion

        #region FrmTaoNguoiDung_Closing
        // Author: khanhlq . Date: 2/13/2006.
        // Modifier: khanhlq. Date:  2/13/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Handles the Closing event of the FrmTaoNguoiDung control.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>
        private void FrmTaoNguoiDung_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (this._isChange)
            {
                DialogResult result = MessageBox.Show(QLNHK.BLL.ThongBao.MSG_Warring_SaveData, QLNHK.BLL.ThongBao.MSG_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    if (!Valid() || !ValidPass())
                    {
                        e.Cancel = true;
                        return;
                    }
                    if (intSuaHayThem == 0)
                    {
                        Save(SaveSuaHayThem.SThemMoi);
                    }
                    else if (intSuaHayThem == 1)
                    {
                        Save(SaveSuaHayThem.SChinhSua);
                    }
                }
                else
                {
                    setChanged(this._isChange = false);
                    this.Close();
                }
                this._isChange = false;
            }
        }
        #endregion

        #endregion

        #region Private Methods

        #region LayNguoiDungChiTiet
        // Author: khanhlq . Date: 2/10/2006.
        // Modifier: khanhlq. Date:  2/10/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Lấy nhóm người dùng đưa vào Grid UGNhomNguoiDung.
        /// </summary>
        private void LayNguoiDungChiTiet()
        {
            objNhomNguoiDung = new Cls_NHOM_NGUOIDUNG();
            dsNhomNguoiDung = objNhomNguoiDung.ListByAll();
            if (dsNhomNguoiDung.Tables[0].Rows.Count != 0)
            {
                DataColumn colTick = new DataColumn();
                colTick.ColumnName = "Tick";
                colTick.DataType = typeof(bool);
                colTick.DefaultValue = false;
                dsNhomNguoiDung.Tables[0].Columns.Add(colTick);
                //dsNhomNguoiDung.Tables[0].AcceptChanges();
                //UGNhomNguoiDung.UpdateData();
                UGNhomNguoiDung.DataSource = dsNhomNguoiDung.Tables[0];

            }
            else
            {
                UGNhomNguoiDung.DataBind();
                //UGNhomNguoiDung.CreationFilter = new EmptyGridCreationFilter("Không có nhóm nào tồn tại trong hệ thống");	
            }
        }
        #endregion

        #region UpdateGridNguoiDungChiTiet

        // Author: khanhlq . Date: 2/10/2006.
        // Modifier: khanhlq. Date:  2/10/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Update các checkbox trong Grid, nếu tồn tại trong người dùng chi tiết thì check vào.
        /// </summary>
        private void UpdateGridNguoiDungChiTiet()
        {
            try
            {
                //lấy danh sách nhóm người dùng chi tiết theo id người dùng
                DataRow[] drNhomNguoiDungChiTiet = objNhomNguoiDungChiTiet.ListByIDNguoiDung(intID_NguoiDung).Tables[0].Select();
                foreach (DataRow drNhom in drNhomNguoiDungChiTiet)
                {
                    //lặp tất cả các row trong Grid nhóm 
                    //để xem ID nhóm người dùng nào tồn tại thì check vào
                    foreach (UltraGridRow urow in UGNhomNguoiDung.Rows)
                    {
                        if (urow.Cells["ID_Nhom_NguoiDung"].Value.ToString().Trim() == drNhom["ID_Nhom_NguoiDung"].ToString().Trim())
                        {
                            urow.Cells["Tick"].Value = 1;
                        }
                    }
                }
                dsNhomNguoiDung.Tables[0].AcceptChanges();
                UGNhomNguoiDung.UpdateData();
            }
            catch (Exception ex)
            {
                Logger.LocalLogger.Instance().WriteMessage(ex);
            }
        }
        #endregion
        #region Save
        // Author: khanhlq . Date: 2/10/2006.
        // Modifier: khanhlq. Date:  2/10/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Lưu dữ liệu với sự lựa chọn là load form thêm danh sách
        /// hay form sửa danh sách người dùng
        /// </summary>
        /// <param name="suahaythem">The suahaythem.</param>

        private void Save(SaveSuaHayThem suahaythem)
        {
            try
            {
                string MatKhauMaHoa = Global.Encrypt(txtMatKhau.Text);
                if (MatKhauMaHoa == "Error")
                {
                    return;
                }
                switch (suahaythem)
                {
                    case SaveSuaHayThem.SChinhSua:
                        int result;
                        if (_bChangePass)
                            result = objNguoiDung.DoUpdate(intID_NguoiDung, Convert.ToInt32(cboHoSoNhanSu.Value), txtNguoiDung.Text, MatKhauMaHoa, DateTime.Now.Date, chkKichHoat.Checked);
                        else
                            result = objNguoiDung.DoUpdate(intID_NguoiDung, Convert.ToInt32(cboHoSoNhanSu.Value), txtNguoiDung.Text, DateTime.Now.Date, chkKichHoat.Checked);
                        if (result != -1)
                        {
                            #region Nếu Grid nhóm có thay đổi
                            DataTable dtChange = dsNhomNguoiDung.Tables[0].GetChanges();
                            //try chỗ này là để khi get change không có sẽ
                            if (dtChange != null)
                            {
                                try
                                {
                                    if (dtChange.Rows.Count > 0)
                                    {
                                        foreach (DataRow rowChanged in dtChange.Rows)
                                        {
                                            //nếu Tick thay đổi từ true sang false 
                                            //thì sẽ xóa dữ liệu
                                            if (rowChanged["Tick"].ToString() == "False")
                                            {
                                                objNhomNguoiDungChiTiet.DoDelete(intID_NguoiDung, Convert.ToInt32(rowChanged["ID_Nhom_NguoiDung"]));
                                            }
                                            //nếu Tick thay đổi từ False sang true
                                            //thì sẽ thêm mới dữ liệu
                                            else if (rowChanged["Tick"].ToString() == "True")
                                            {
                                                objNhomNguoiDungChiTiet.DoInsert(intID_NguoiDung, Convert.ToInt32(rowChanged["ID_Nhom_NguoiDung"]));
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.LocalLogger.Instance().WriteMessage(ex);
                                }
                            }
                            #endregion
                            setChanged(this._isChange = false);
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show(QLNHK.BLL.ThongBao.MSG_Warning_FrmTaoNguoiDung_ThemNguoiDung, QLNHK.BLL.ThongBao.MSG_Caption_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;
                    case SaveSuaHayThem.SThemMoi:
                        int id_NguoiDung = objNguoiDung.DoInsert(Convert.ToInt32(cboHoSoNhanSu.Value), txtNguoiDung.Text, MatKhauMaHoa, DateTime.Now.Date, chkKichHoat.Checked, false);
                        if (id_NguoiDung != -1)
                        {
                            #region Nếu cell tick có chọn thì sẽ thêm mới vào nhóm người dùng chi tiết theo id người dùng
                            foreach (UltraGridRow row in UGNhomNguoiDung.Rows)
                            {
                                if (row.Cells["Tick"].Text == "True")
                                {
                                    objNhomNguoiDungChiTiet.DoInsert(id_NguoiDung, Convert.ToInt32(row.Cells["ID_Nhom_NguoiDung"].Text));
                                }
                            }
                            #endregion
                            this.DialogResult = DialogResult.OK;
                            setChanged(this._isChange = false);
                            this.Close();
                        }
                        else if (id_NguoiDung == -1)
                        {
                            MessageBox.Show(QLNHK.BLL.ThongBao.MSG_Warning_FrmTaoNguoiDung_ThemNguoiDung, QLNHK.BLL.ThongBao.MSG_Caption_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            return;
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.LocalLogger.Instance().WriteMessage(ex);
            }
        }
        #endregion

        #region blverifyValidate
        /// Author: khanhlq . Date: 2/13/2006.
        /// Modifier: khanhlq. Date:  2/13/2006.
        /// Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Blverifies the validate.
        /// </summary>
        /// <returns>true nếu như đúng, false : thiết lập lại để khi chạy lại hàm</returns>
        private bool blverifyValidate()
        {
            try
            {
                if (txtMatKhau.Text.Length < 6)
                {
                    errorUser.SetError(txtMatKhau, QLNHK.BLL.ThongBao.MSG_Warning_FrmMatKhauQuaNgan);
                    txtMatKhau.Focus();
                    return true;
                }
                else
                {
                    errorUser.SetError(txtMatKhau, "");
                }
                return false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, QLNHK.BLL.ThongBao.MSG_Caption_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return true;
            }
        }
        #endregion



        #region setChanged
        // Author: khanhlq . Date: 2/5/2006.
        // Modifier: khanhlq. Date:  2/5/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Sets the changed.
        /// </summary>
        /// <param name="isChanged">nếu như true là có sự thay đổi.</param>
        private void setChanged(bool isChanged)
        {
            if (isChanged)
            {
                this.Text = _caption + "*";
                this.btnLuu.Enabled = isChanged;
            }
            else
            {
                this.Text = _caption;
                this.btnLuu.Enabled = isChanged;
            }
        }
        #endregion

        private void txtMatKhau_TextChanged(object sender, EventArgs e)
        {
            _bChangePass = true;
        }

        #endregion

        private void UGNhomNguoiDung_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
        {


        }

    }
}
